const base = require("../../util.js")
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    vip: '3',
    platform: "",
    userInfo: '',
  },
  onLoad(options) {
    console.log(base._t());
    let userInfo = wx.getStorageSync('userInfo');
    if (userInfo) {
      this.userlogin();
    }

    this.getVipInfo();


    this.setData({
      $t: base._t(),
      platform: app.globalData.platform,
    })
  },

  select_vip(e) {
    console.log(e);
    let vip = e.currentTarget.dataset.vip;
    this.setData({
      vip: vip,
    })
  },

  userlogin() {
    let that=this;
    wx.getUserProfile({
      desc: '用于完善会员资料',
      success(res) {
        // console.log(res.userInfo);
        wx.login({
          success(res1) {
            // console.log(res1);
            wx.request({
              url: app.globalData.RequestUrl + 'wxuserLogin',
              method: "POST",
              data: {
                "code": res1.code,
                "userInfo": res.userInfo
              },
              success(res) {
                that.setData({
                  userInfo: res.data.userInfo,
                })
              }
            })
          }
        })
      }
    })
  },


  getVipInfo() {
    let that = this;
    wx.request({
      url: app.globalData.RequestUrl + 'getVipInfo',
      method: "POST",
      data: "",
      success(res) {
        console.log( res.data.data);
        that.setData({
          vipInfo: res.data
        });
      }
    })
  },
})